package serlvet;

import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.log4j.Logger;

/**
 * Create By IntelliJ IDEA
 *
 * @Author: jsonor
 * @Create-Time: 2017/9/25 13:53
 * @Description: Servlet的生命周期
 */
public class LifeServlet implements Servlet {

  private static final Logger logger = Logger.getLogger(LifeServlet.class);

  /***
   * servlet被初始化是调用的方法
   * @param config
   * @throws ServletException
   */
  public void init(ServletConfig config) throws ServletException {
    logger.fatal("life Servlet init success");
  }

  public ServletConfig getServletConfig() {
    return null;
  }

  /***
   * Http请求接受到时调用的方法
   * @param req
   * @param res
   * @throws ServletException
   * @throws IOException
   */
  public void service(ServletRequest req, ServletResponse res)
      throws ServletException, IOException {
    logger.fatal("get message from user web-br");
  }

  public String getServletInfo() {
    return null;
  }

  /***
   * 当前Servlet被销毁时调用的方法
   */
  public void destroy() {
    logger.fatal("the servlet destroy");
  }
}
